/***************************************************************************
 *   Copyleft 2006-2007 by												   *
 *	 Iwanicki Krzysztof													   *
 *   <gamma.mini.pw.edu.pl/~iwanickik>									   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 ***************************************************************************/
#ifndef __OBJECT3D_H__
#define __OBJECT3D_H__

#include "../../Types/Types.h"
#include "../Graphics/Color.h"
#include "../Renderer/Renderer.h"
#include "../Renderer/ProjectionPlane.h"
#include "../Math/Math.h"


class Object3D {
protected:
	static cInt mCnt;
	Matrix4D mMatrix;
	Matrix4D mObjectMatrix;
	cWinColor mColor;
	cBool mVisible;
	cInt mID;

	cInt mNrOfVertices;
	Point4D *mVertexTable;

	struct EdgePointer {
		cInt mBegin;
		cInt mEnd;
	};
	cInt mNrOfEdges;
	EdgePointer *mEdgeTable;

	
	cBool Clip(Point4D &a, Point4D &b, ProjectionPlane& plane);
public:
	
	/**************************************************************
	* Constructors                                                *
	***************************************************************/
	Object3D();
	Object3D(cInt iVertices, cInt iEdges);
	virtual ~Object3D();
	
	/**************************************************************
	* Other helpful functions                                     *
	***************************************************************/
	virtual cVoid Render(Renderer& renderer, Matrix4D& matrix, ProjectionPlane& plane);
	virtual cVoid Render(Renderer& renderer, Matrix4D& matrix, ProjectionPlane& plane, cWinColor color);
	virtual cVoid DisplayInfo(Renderer& renderer) { }
	virtual cVoid Transform(Matrix4D& matrix);
	virtual cVoid Transform(Matrix4D& matrix, cBool bRemember);
	virtual cVoid Update(cInt iVertices, cInt iEdges);
	virtual Matrix4D GetTransformationMatrix();
	virtual cInt GetID();
	cVoid SetVisible();
	cBool GetVisible();
	virtual cChar* GetName() = 0;
	static cInt NrOfAllCreatedObjects();
};

#endif // __OBJECT3D_H__